'''The latex2html_converter module provides a simple, lossy, conversion
from TeX or Latex code to HTML. It is appropriate for small fragements
of text, such as author names or article titles as found in a
bibliography.

@copyright: (c) 2010, Benjamin Kalish

@license:
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.
'''

from latex_converter import LatexConverter

class Latex2HTMLConverter( LatexConverter ):
    def double_left_quote(self):
        return '"'
    
    def double_right_quote(self):
        return '"'

    def em_dash(self):
        return '&mdash;'

    def en_dash(self):
        return '&ndash;'
    
    def inverted_question_mark(self):
        return '&iquest;'
   
    def inverted_exclamation_mark(self):
        return '&iexcl;'
    
    def nonbreaking_space(self):
        return '&nbsp;'
    
    def paragraph_break(self):
        return '<br>'
        
    def acute(self, arg):
        map = { 'a' : '&aacute;',
                'A' : '&Aacute;',
                'e' : '&eacute;',
                'E' : '&Eacute;',
                'i' : '&iacute;',
                'I' : '&Iacute;',
                'o' : '&oacute;',
                'O' : '&Oacute;',
                'u' : '&uacute;',
                'U' : '&Uacute;',
                'Y' : '&yacute;',
                'Y' : '&Yacute;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return arg + '&#769;'        

    def aleph(self):
        return '&alefsym;'
    
    def ampersand(self):
        return '&amp;'

    def breve(self, arg):
        return arg + '&#774;'
    
    def capital_l_with_stroke(self):
        return '&#0321'
    
    def capital_thorn(self):
        return '&THORN;'
            
    def caron(self, arg):
        map = { 's' : '&scaron;',
                'S' : '&Scaron;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return arg + '&#780;'
            
    def cedilla(self, arg):
        map = { 'c' : '&ccedil;',
                'C' : '&Ccedil;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return arg + '&#807;'
            
    def circumflex(self, arg):
        map = { 'a' : '&acirc;',
                'A' : '&Acirc;',
                'e' : '&ecirc;',
                'E' : '&Ecirc;',
                'i' : '&icirc;',
                'I' : '&Icirc;',
                'o' : '&ocirc;',
                'O' : '&Ocirc;',
                'u' : '&ucirc;',
                'U' : '&Ucirc;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return arg + '&#770;'
    
    def cyrillic_hard_sign(self):
        return '&#1098;'
        
    def cyrillic_soft_sign(self):
        return '&#1100;'

    def dot_above(self, arg):
        return arg + '&#775;'

    def dot_below(self, arg):
        return arg + '&#803;'

    def double_acute(self, arg):
        return arg + '&#779;'
    
    def element_of(self):
        return "&isin;"

    def eszett(self):
        return '&szlig;'
    
    def eth(self):
        return '&eth;'
    
    def grave(self, arg):
        map = { 'a' : '&agrave;',
                'A' : '&Agrave;',
                'e' : '&egrave;',
                'E' : '&Egrave;',
                'i' : '&igrave;',
                'I' : '&igrave;',
                'o' : '&ograve;',
                'O' : '&Ograve;',
                'u' : '&ugrave;',
                'U' : '&Ugrave;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return arg + '&#768;'
            
    def low_line(self, arg):
        return arg + '&#818;'

    def macron(self, arg):
        return arg + '&#772;'

    def partial(self):
        return '&part;'

    def plus_or_minus(self):
        return '&plusmn;'

    def ring_above(self, arg):
        map = { 'a' : '&aring;',
             'A' : '&Aring;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return arg + '&#778;'
    
    def small_l_with_stroke(self):
        return '&#0322;'

    def small_l_with_stroke(self):
        return '&#0322;'

    def small_thorn(self):
        return '&thorn;'
        
    def square_root(self, arg):
        return '&radic;(' + arg + ')'

    def sterling(self):
        return '&pound;'
    
    def superscript(self, arg):
        return '<sup>' + arg + '</sup>'

    def subscript(self, arg):
        return '<sub>' + arg + '</sub>'

    def tilde(self, arg):
        map = {'a' : '&atilde;',
           'A' : '&Atilde;',
           'o' : '&otilde;',
           'O' : '&Otilde;',
           'n' : '&ntilde;',
           'N' : '&Ntilde;'}
        if map.has_key(arg):
            return map[arg]
        else:
            return '&#771;'

    def umlaut(self, arg):
        map = {'a' : '&auml;',
               'A' : '&Auml;',
               'e' : '&euml;',
               'E' : '&Euml;',
               'i' : '&iuml;',
               '\\i' : '&iuml;',
               'I' : '&iuml;',
               'o' : '&ouml;',
               'O' : '&Ouml;',
               'u' : '&uuml;',
               'U' : '&Uuml;',
               'y' : '&yuml;'}
        if map.has_key(arg):
            return map[arg]
        return arg + '&#776;'
    
    def small_alpha(self):
        return '&alpha;'

    def small_beta(self):
        return '&beta;'
        
    def small_gamma(self):
        return '&gamma;'

    def small_delta(self):
        return '&delta;'

    def small_epsilon(self):
        return '&epsilon;'

    def small_zeta(self):
        return '&zeta;'

    def small_eta(self):
        return '&eta;'

    def small_theta(self):
        return '&theta;'

    def small_iota(self):
        return '&iota;'

    def small_kappa(self):
        return '&kappa;'

    def small_lambda(self):
        return '&lambda;'

    def small_mu(self):
        return '&mu;'

    def small_nu(self):
        return '&nu;'

    def small_xi(self):
        return '&xi;'

    def small_omicron(self):
        return '&omicron;'

    def small_pi(self):
        return '&pi;'

    def small_rho(self):
        return '&rho;'

    def small_sigma(self):
        return '&sigma;'

    def small_tau(self):
        return '&tau;'

    def small_upsilon(self):
        return '&upsilon;'

    def small_phi(self):
        return '&phi;'

    def small_chi(self):
        return '&chi;'

    def small_psi(self):
        return '&psi;'

    def small_omega(self):
        return '&omega;'

    def capital_alpha(self):
        return '&Alpha;'

    def capital_beta(self):
        return '&Beta;'

    def capital_gamma(self):
        return '&Gamma;'

    def capital_delta(self):
        return '&Delta;'

    def capital_epsilon(self):
        return '&Epsilon;'

    def capital_zeta(self):
        return '&Zeta;'

    def capital_eta(self):
        return '&Eta;'

    def capital_theta(self):
        return '&Theta;'

    def capital_iota(self):
        return '&Iota;'

    def capital_kappa(self):
        return '&Kappa;'

    def capital_lambda(self):
        return '&Lambda;'

    def capital_mu(self):
        return '&Mu;'

    def capital_nu(self):
        return '&Nu;'

    def capital_xi(self):
        return '&Xi;'

    def capital_omicron(self):
        return '&Omicron;'

    def capital_pi(self):
        return '&Pi;'

    def capital_rho(self):
        return '&Rho;'

    def capital_sigma(self):
        return '&Sigma;'

    def capital_tau(self):
        return '&Tau;'

    def capital_upsilon(self):
        return '&Upsilon;'

    def capital_phi(self):
        return '&Phi;'

    def capital_chi(self):
        return '&Chi;'

    def capital_psi(self):
        return '&Psi;'

    def capital_omega(self):
        return '&Omega;'
        
    def small_o_slash(self):
        return '&oslash;'
        
    def captial_o_slash(self):
        return '&Oslash;'
